#include <iostream>
using namespace std;

class Person
{
public:
  Person()
  {
    cout << "Person的默认构造函数调用" << endl;
  }

  Person(int age, int height)
  {
    m_age = age;
    m_height = new int(height);
    cout << "Person的有参构造函数调用" << age << endl;
  }

  Person(const Person &p) {
    m_age = p.m_age;
    m_height = new int(*p.m_height);
  }

  ~Person()
  {
    // 析构代码，将堆区开辟数据做释放
    if (m_height != NULL)
    {
      delete m_height;
    }

    cout << "Person的析构函数调用" << endl;
  }

  int m_age;
  int *m_height;
};

void test01()
{
  Person p1(18, 160);

  cout << "p1的年龄为：" << p1.m_age << "\t身高为：" << *p1.m_height << endl;

  Person p2(p1);
  cout << "p2的年龄为：" << p2.m_age << "\t身高为：" << *p1.m_height << endl;
}

int main(int argc, char const *argv[])
{
  test01();

  return 0;
}